am__tar += --owner root --group root --mode a+rX,go-w

WARN_OPTS = \
	-W -Wall \
	-Wno-pointer-arith \
	-Wno-unused-local-typedefs \
	-Wno-unused-parameter

WARN_OPTS_C = \
	-Wmissing-prototypes

AM_CPPFLAGS =	-I .
AM_CFLAGS =	-std=gnu11 $(WARN_OPTS) ${WARN_OPTS_C}
AM_CXXFLAGS =	-std=gnu++11 $(WARN_OPTS) ${WARN_OPTS_CC} -fno-exceptions
AM_LIBFLAGS =	-Wl,-shared -fPIC

pkglibdir =		$(libdir)/${PACKAGE}
testdir =		$(pkglibdir)/testsuite
pkgconfigdir =		${libdir}/pkgconfig


bin_PROGRAMS = \
	bayer2rgb

test_PROGRAMS = \
	testsuite/gen-image

dist_test_SCRIPTS = \
	testsuite/run-test \
	testsuite/create-cols \
	testsuite/performance

pkgconfig_DATA = \
	bayer2rgb3.pc

AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = \
	$(dist_test_SCRIPTS)

lib_LTLIBRARIES = \
	libbayer2rgb3.la

pkginclude_HEADERS = \
	src/bayer2rgb.h

neon_SRC = \
	src/convert-neon.c \
	src/convert-neon_tests.inc.h \
	src/convert-neon-body-outer.inc.h \
	src/convert-neon-body-bayer8.inc.h \
	src/convert-neon-infmt.inc.h

convert_c_SRC_CC = \
	src/convert-internal.hh \
	src/convert-dumb.cc \
	src/reduce-bpp-dump.cc

libbayer2rgb3_la_SOURCES = \
	src/compiler.h \
	src/bayer2rgb.h \
	src/bayer2rgb-internal.h \
	src/convert.c \
	src/convert-c-opt.c \
	src/convert-c-opt_0.inc.h \
	src/convert-c-opt_1.inc.h \
	src/convert-c-body-outer.inc.h \
	src/convert-c-body-inner.inc.h

dist_EXTRA_libbayer2rgb3_la_SOURCES = \
	$(neon_SRC) \
	${convert_c_SRC_CC}

## optional C++ sources
if HAVE_CPLUSPLUS
AM_CPPFLAGS += -DHAVE_CPLUSPLUS
libbayer2rgb3_la_SOURCES += \
	${convert_c_SRC_CC}
endif

if HAVE_NEON
AM_CPPFLAGS += -DHAVE_NEON
libbayer2rgb3_la_SOURCES += \
	$(neon_SRC)
endif

bayer2rgb_SOURCES = \
	src/main.c \
	src/bayer2rgb.ggo

nodist_bayer2rgb_SOURCES = \
	src/bayer2rgb-cmdline.c \
	src/bayer2rgb-cmdline.h

bayer2rgb_LDADD = \
	libbayer2rgb3.la

testsuite_gen_image_SOURCES = \
	testsuite/gen-image.c \
	testsuite/gen-image.ggo

nodist_testsuite_gen_image_SOURCES = \
	testsuite/gen-image-cmdline.c \
	testsuite/gen-image-cmdline.h

BUILT_SOURCES = \
	$(nodist_bayer2rgb_SOURCES) \
	$(nodist_testsuite_gen_image_SOURCES)

AM_TESTS_ENVIRONMENT = \
	PATH=$(abs_top_builddir):$(PATH)

TESTS = \
	testsuite/run-test \
	testsuite/performance

CLEANFILES = \
	$(nodist_bayer2rgb_SOURCES) \
	$(nodist_testsuite_gen_image_SOURCES)

.%-cmdline.stamp:	%.ggo
	@$(MKDIR_P) $(@D)
	$(GENGETOPT) -i $< -F $*-cmdline
	touch $@

%-cmdline.c %-cmdline.h: .%-cmdline.stamp
	@:

dist:	check-scm-clean check-scm-tagged

check-scm-clean:
	$(GIT) -C ${abs_top_srcdir} status --porcelain  > .tmp.git-status
	@! test -s .tmp.git-status || { \
		echo "***"; \
		echo "*** ERROR: git repository not clean"; \
		echo "***"; \
		cat .tmp.git-status; \
		false; \
	} >&2

check-scm-tagged:
	$(GIT) -C ${abs_top_srcdir} tag --contains HEAD > .tmp.git-tagged
	@test -s .tmp.git-tagged || { \
		echo "***"; \
		echo "*** ERROR: HEAD not tagged"; \
		echo "***"; \
		false; \
	} >&2

.PHONY:		check-scm-clean check-scm-tagged
